import math

result = 0.1 + 0.2
print(result == 0.3)    # --> False

# 使用math.isclose()函数比较浮点数
# rel_tol 是相对容差，abs_tol 是绝对容差
print(math.isclose(result, 0.3)) # True
print(math.isclose(result, 0.3, rel_tol=0.0001,abs_tol=0.0001)) # True

a=-0.0
b=0.0
print("a == 0.0:",a == 0.0) # True
print("b == 0.0:",b == 0.0) # True
print(math.isclose(a, 0.0)) # True